# coding=utf-8
# Time : 2020/10/9 15:08
# Author : huxin
import datetime

from flask import Flask
from common.YmlUtil import YmlUtil
import os

from dataGenerator.dataHub.changshaDeviceData import changshaData
from dataGenerator.ergongAlarm.ergongAlarm import ergongAlarm
from dataGenerator.shenshui.SSdeviceGenerator import SSdeviceGenerator
from dataGenerator.shenshui.device_pump_run_efficiency import device_pump_run_efficiency
from dataGenerator.shenshui.device_pump_runpower import device_pump_runpower
from dataGenerator.shenshui.peakshift_water_plant import peakshift_water_plant
from dataGenerator.shenshui.tankLevel import openValveState, tanklevelValue
from dataGenerator.zysDevice.Kafdrop import kaf
from dataGenerator.zysDevice.ZYSdeviceGenerator import ZYSdeviceGenerator
from dataGenerator.zysDevice.dayTableGenerator import dayTableGenerator
from dataGenerator.zysDevice.hourTableGenerator import hourTableGenerator
from dataGenerator.zysDevice.mqttData import mqttGenerator
from dataGenerator.zysDevice.realtimeDataGenerator import realtimeGenerator

from view import *
from flask_apscheduler import APScheduler
from task.task import *

app = create_app()
abPath = os.path.abspath(__file__)
path = abPath.replace('py', 'yml')
port = YmlUtil.readYml(path=path, key='server', para='port')

if __name__ == '__main__':
    # 配置统一的调度任务类
    app.config.from_object(SchedulerConfig())
    # app.config.from_pyfile(filePath)
    scheduler = APScheduler()
    scheduler.init_app(app)
    # 临时增加的定时任务
    #scheduler.add_job(id= "ergongAlarm",func=realtimeGenerator,trigger='cron', second='*/5')
    scheduler.add_job(id="ergongAlarm", func=kaf, trigger='cron', second='*/5')

    scheduler.start()
    app.run(host='0.0.0.0', port=port, debug=False)

